﻿<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using DBUtility;
using System.Text;
using System.Data;

public class Handler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string str = string.Empty;

        if (context.Request.Params["indicator"] != null)
        {
            //str = GetIndicatorValue(context.Request.Params["tablename"].ToString(), context.Request.Params["where"], context.Request.Params["sort"]);
        }
        else if (context.Request.Params["tablename"] != null)
        {
            //str = GetPerValue(context.Request.Params["tablename"].ToString(), context.Request.Params["resourcetypeid"], context.Request.Params["type"], context.Request.Params["sort"], context.Request.Params["where"]);
        }
        else
        {
            str = "{success:false,data:[]}";
        }
        context.Response.ContentType = "text/json";
        context.Response.Write(@str);
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
 /*   public string GetIndicatorValue(string TABLENAME, string strWhere, string SORT)
    {
        string strReturn = "{rows:[";
        try
        {
            DataSet ds = new BLL.Common.ResourceStatus().GetIndicatorValue(TABLENAME, strWhere, SORT);
            object orv = new object();
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                int length = ds.Tables[0].Columns.Count;
                int colCount = length;
                string[] columns = new string[length];
                for (int i = 0; i < length; i++)
                {
                    columns[i] = ds.Tables[0].Columns[i].ColumnName;
                }
                length = ds.Tables[0].Rows.Count;
                // length = 1;
                for (int i = 0; i < length; i++)
                {
                    strReturn += "{";
                    for (int j = 0; j < colCount; j++)
                    {
                        orv = ds.Tables[0].Rows[i][columns[j]];
                        strReturn += "\"" + columns[j].ToString() + "\":\"" + (orv == null ? "" : orv.ToString()) + "\"";
                        if (j < colCount - 1)
                        {
                            strReturn += ",";
                        }
                    }
                    strReturn += "}";
                    if (i < length - 1)
                    {
                        strReturn += ",";
                    }
                }
                strReturn += "]}";
            }
            else
            {
                strReturn += "]}";
            }
        }
        catch (Exception)
        {
            strReturn += "]}";
            //throw;
        }
        return strReturn;
    }*/
   /* public string GetPerValue(string TABLENAME, string RESOURCETYPEID, string TYPE, string SORT, string strWhere)
    {
        string strReturn = "{success:";
        try
        {
            DataSet ds = new BLL.Common.ResourceStatus().GetResourceValue(TABLENAME, RESOURCETYPEID, TYPE, SORT, strWhere);
            object orv = new object();
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                int length = ds.Tables[0].Columns.Count;
                int colCount = length;
                string[] columns = new string[length];
                for (int i = 0; i < length; i++)
                {
                    columns[i] = ds.Tables[0].Columns[i].ColumnName;
                }
                strReturn += "true,data:[";
                length = ds.Tables[0].Rows.Count;
                // length = 1;
                for (int i = 0; i < length; i++)
                {
                    strReturn += "{";
                    for (int j = 0; j < colCount; j++)
                    {
                        orv = ds.Tables[0].Rows[i][columns[j]];
                        strReturn += "\"" + columns[j].ToString() + "\":\"" + (orv == null ? "" : orv.ToString()) + "\"";
                        if (j < colCount - 1)
                        {
                            strReturn += ",";
                        }
                    }
                    strReturn += "}";
                    if (i < length - 1)
                    {
                        strReturn += ",";
                    }
                }
                strReturn += "]}";
            }
            else
            {
                strReturn += "false,data:[]}";
            }
        }
        catch (Exception)
        {
            strReturn += "false,data:[]}";
            //throw;
        }
        return strReturn;
    }*/
}